﻿
Imports webctrl

Public Module helper
    Public Function generateXhtmlPage(ByVal context As httpContext) As xhtmlpage
        assert(Not context Is Nothing, "context is nothing.")
        Dim rtn As xhtmlpage = Nothing
        rtn = context.createControl(New xhtmlpage())
        Dim lang1 As String = Nothing
        Dim lang2 As String = Nothing
        languageSeparate(context.language(), lang1, lang2)

        Dim c As String = Nothing
        If Not isemptystring(lang1) AndAlso Not isemptystring(lang2) Then
            c = lang1 + character.blank + lang2
        ElseIf Not isemptystring(lang1) Then
            c = lang1
        ElseIf Not isemptystring(lang2) Then
            c = lang2
        End If

        If Not isemptystring(c) Then
            If isemptystring(rtn.body().class) Then
                rtn.body().class += character.blank
            End If
            rtn.body().class += c
        End If

        Return rtn
    End Function

#If RETIRED Then
    Public Sub languageSeparate(ByVal context As httpContext, _
                                ByRef full As String, ByRef market As String, ByRef language As String)
        assert(Not context Is Nothing, "context is nothing.")
        copy(full, context.language())
        languageSeparate(full, market, language)
    End Sub
#End If
End Module
